package com.caine.multithread;

/**
 * @Author: CaineZhu
 * @Description:  同一个实例中synchronized修饰的方法互斥(包括)
 * @Date: Created in 15:05 2020/12/10
 * @Modified By:
 */
public class Demo04 {

    public synchronized void say(){
        System.out.println("say1");
        for (;;){
            ;
        }
    }

    public synchronized  void say2(){
        System.out.println("say2");
    }

    public static void main(String[] args) {
        Demo04 test = new Demo04();
        new Thread(()->test.say()).start();
        new Thread(()->test.say2()).start();
    }
}
